<include file="Public/header"/>

<div id="app">
    <!-- sidebar -->
    <include file="Public/left"/>
    <!-- / sidebar -->
    <div class="app-content">
        <!-- start: TOP NAVBAR -->
        <include file="Public/headernav"/>
        <!-- end: TOP NAVBAR -->
        <div class="main-content">
            <div class="wrap-content container" id="container">
                <!-- start: PAGE TITLE -->
                <section id="page-title">
                    <div class="row">
                        <div class="col-sm-8">
                            <h1 class="mainTitle">活动列表</h1>
                            <span class="mainDescription"></span>
                        </div>
                        <nav id="cl-effect-10" class="links cl-effect-10">
                            <a data-hover="新增" href="{:U('admin/Draw/draw_edit')}"><span>新增</span></a>

                        </nav>
                        <!-- <ol cla
                <!-- <ol class="breadcrumb">
                    <li>
                        <span>Pages</span>
                    </li>
                    <li class="active">
                        <span>Blank Page</span>
                    </li>
                </ol> -->
                    </div>
                </section>
                <!-- end: PAGE TITLE -->
                <!-- start: YOUR CONTENT HERE -->
                <table class="table table-hover" id="sample-table-1">
                    <thead>
                    <tr>
                        <th class="center">#</th>
                        <th>奖品类型</th>
                        <th>奖品面值</th>
                        <th>中奖基数</th>
                        <th>中奖率</th>
                        <th>状态</th>
                        <th>审核状态</th>
                        <th>新增时间</th>
                        <th class="center">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="data['list']" id="val">
                        <tr>
                            <td></td>
                            <td>{$val.type_name}</td>
                            <td>
                                <if condition="$val['draw_type'] neq 5">
                                    {$val.draw_value}
                                    <else/>
                                    <a href="{:U('wap/goods/goods_detail')}?id={$val.draw_value}">{$val.goods_msg}</a>
                                </if>
                            </td>
                            <td>{$val.draw_chances_value}</td>
                            <td>{$val.odds}%</td>
                            <td id="draw_status_{$val.id}">
                                <if condition="$val.draw_status eq 1">
                                    <a href="javascript:void(0)" onclick="setStatus({$val.draw_status},{$val.id})"
                                       class="btn btn-transparent btn-xs" tooltip="Edit" tooltip-placement="top"
                                       data-toggle="tooltip" data-original-title="有效"><i class="fa fa-check-circle"></i></a>
                                    <else/>
                                    <a href="javascript:void(0)" onclick="setStatus({$val.draw_status},{$val.id})"
                                       class="btn btn-transparent btn-xs" tooltip="Edit" tooltip-placement="top"
                                       data-toggle="tooltip" data-original-title="无效"><i class="fa fa-check-circle" style="color:#ccc;" value="1"></i></a>
                                </if>
                            </td>
                            <td id="is_shenghe_{$val.id}">
                                <if condition="$val.is_shenghe eq 1">
                                    <a href="javascript:void(0)" onclick="setVerify({$val.is_shenghe},{$val.id})"
                                       class="btn btn-transparent btn-xs" tooltip="Edit" tooltip-placement="top"
                                       data-toggle="tooltip" data-original-title="已审核"><i class="fa fa-check-circle"></i></a>
                                    <else/>
                                    <a href="javascript:void(0)" onclick="setVerify({$val.is_shenghe},{$val.id})"
                                       class="btn btn-transparent btn-xs" tooltip="Edit" tooltip-placement="top"
                                       data-toggle="tooltip" data-original-title="未审核"><i class="fa fa-check-circle" style="color:#ccc;" value="1"></i></a>
                                </if>
                            </td>
                            <td>{$val.add_time|date="Y-m-d",###}</td>
                            <td>
                                <div class="visible-md visible-lg hidden-sm hidden-xs">
                                    <a href="{:U("Admin/Draw/draw_edit",array('id'=>$val['id']))}"
                                    class="btn btn-transparent btn-xs" tooltip="Edit" tooltip-placement="top"
                                    data-toggle="tooltip" data-original-title="编辑">
                                    <i class="fa fa-pencil"></i></a>
                                    <a href="{:U("Admin/Draw/draw_del",array('id'=>$val['id']))}"
                                    class="btn btn-transparent btn-xs" tooltip="Edit" tooltip-placement="top"
                                    data-toggle="tooltip" onclick="return confirm('确取删除该商品？')"
                                    data-original-title="删除"><i class="fa fa-trash-o"></i></a>
                                </div>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
                <div class="col-md-12 pages" align="center">{$data['page']|default='暂无数据'}</div>
                <!-- end: YOUR CONTENT HERE -->
            </div>
        </div>
    </div>
    <!--  FOOTER and SETTINGS -->

    <include file="Public/footer"/>
    <!-- end: FOOTER -->
    <!-- start: OFF-SIDEBAR -->
    <!-- end: OFF-SIDEBAR -->

</div>
</div>
<!-- start: MAIN JAVASCRIPTS -->
<include file="Public/javascript"/>
<include file="Public/javascript_datepicker"/>
<script type="text/javascript">
    function setStatus(status,id) {
        (status == 1) ? status = 0 : status = 1;
        var vain='<a href="javascript:void(0)" onclick="setStatus('+status+','+id+')"class="btn btn-transparent btn-xs" tooltip="Edit"' +
                'tooltip-placement="top" data-toggle="tooltip" data-original-title="有效">' +
                '<i class="fa fa-check-circle"></i></a>';
        var inVain = '<a href="javascript:void(0)" onclick="setStatus('+status +','+id+')"class="btn btn-transparent btn-xs"' +
                'tooltip="Edit" tooltip-placement="top" data-toggle="tooltip" data-original-title="无效">' +
                '<i class="fa fa-check-circle" style="color:#ccc;"></i></a>';
        $.ajax({
            url:'{:U("admin/Draw/draw_edit")}?id='+id,
            type:'post',
            data:'draw_status='+status,
            dataType:'json',
            success:function(data){
                if(data.status){
                    $('#draw_status_'+id).empty();
                    if(status){
                        $('#draw_status_' + id).append(vain);
                    }else{
                        $('#draw_status_' + id).append(inVain);
                    }
                    layer.msg('操作成功', {icon: 6});
                }
            }
        })
    }
    function setVerify(status, id) {
        (status == 1) ? status = 0 : status = 1;
        var vain = '<a href="javascript:void(0)" onclick="setVerify(' + status + ',' + id + ')" class="btn btn-transparent btn-xs"' +
                'tooltip="Edit" tooltip-placement="top" data-toggle="tooltip" data-original-title="审核">' +
                '<i class="fa fa-check-circle"></i></a>';
        var inVain = '<a href="javascript:void(0)" onclick="setVerify(' + status + ',' + id + ')" class="btn btn-transparent btn-xs" ' +
                'tooltip="Edit" tooltip-placement="top" data-toggle="tooltip" data-original-title="未审核">' +
                '<i class="fa fa-check-circle" style="color:#ccc;"></i></a>';
        $.ajax({
            url: '{:U("admin/Draw/setVerify")}?id=' + id,
            type: 'post',
            data: 'is_shenghe=' + status,
            dataType: 'json',
            success: function (data) {
                if (data) {
                    $('#is_shenghe_'+id).empty();
                    if (status) {
                        $('#is_shenghe_' + id).append(vain);
                    } else {
                        $('#is_shenghe_' + id).append(inVain);
                    }
                    layer.msg('操作成功', {icon:6});
                }else{
                    layer.msg('操作失败',{icon:5});
                }
            }
        })
    }
</script>
<!-- end: CLIP-TWO JAVASCRIPTS -->
</body>
</html>
